<template>
  <div class="goods">
    <div class="menu-wrapper" ref="menuWrapper">
      <ul>
        <li v-for="item in goods" :key="item.name" class="menu-item">
          <span class="text"><span v-show="item.type>0" class="icon" :class="classMap[item.type]"></span>{{ item.name }}</span>
        </li>
      </ul>
    </div>
    <div class="foods-wrapper" ref="foodWrapper">
      <ul>
        <li v-for="item in goods" :key="item.name" class="food-list">
          <div class="list-name">
          <h1>{{ item.name }}</h1>
          </div>
          <div v-for="item1 in item.foods" :key="item1.name" class="food">
            <div class="icon"><img :src="item1.icon"></div>
            <div class="info">
              <span class="title">{{ item1.name }}</span>
              <span class="desc" v-show="item1.description" >{{ item1.description }}</span>
              <span class="rating">月售{{ item1.sellCount }}份  好评率{{ item1.rating }}%</span>
              <span class="price">
                <span class="nowP">&yen;{{ item1.price }}</span>
                <s class="oldP" v-show="item1.oldPrice">&yen;{{ item1.oldPrice }}</s>
              </span>
            </div>
            <div class="buy"></div>
          </div>
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
import Bscroll from 'better-scroll'
export default {
  data () {
    return {
      goods: {},
      listHeight: []
    }
  },
  props: {
    seller: {}
  },
  created () {
    this.foodLists = this.goods.length
    this.$http.get('/api/goods').then((res) => {
      res = res.body
      if (res.errno === 0) {
        this.goods = res.data
        this._initScroll()
      }
    })
    this.classMap = ['decrease', 'discount', 'special', 'invoice', 'guarantee']
  },
  methods: {
    _initScroll () {
      this.menuScroll = new Bscroll(this.$refs.menuWrapper, {})
      this.foodScroll = new Bscroll(this.$refs.foodWrapper, {})
    }
  }
}
</script>

<style lang="scss" scoped>
@media screen and (-webkit-min-device-pixel-ratio: 2.0) {
  .icon.decrease{
    background-image: url('./decrease_3@2x.png')
  }
  .icon.discount{
    background-image: url('./discount_3@2x.png')
  }
  .icon.guarantee{
    background-image: url('./guarantee_3@2x.png')
  }
  .icon.invoice{
    background-image: url('./invoice_3@2x.png')
  }
  .icon.special{
    background-image: url('./special_3@2x.png')
  }
}
@media screen and (-webkit-min-device-pixel-ratio: 3.0) {
  .icon.decrease{
    background-image: url('./decrease_3@3x.png')
  }
  .icon.discount{
    background-image: url('./discount_3@3x.png')
  }
  .icon.guarantee{
    background-image: url('./guarantee_3@3x.png')
  }
  .icon.invoice{
    background-image: url('./invoice_3@3x.png')
  }
  .icon.special{
    background-image: url('./special_3@3x.png')
  }
}
  .goods{
    position:absolute;
    width: 100%;
    top: 174px;
    display: flex;
    bottom: 46px;
    overflow: hidden;
    .menu-wrapper{
      flex: 0 0 80px;
      width: 80px;
      background: #f3f5f7;
      .menu-item{
        display: table;
        height: 54px;
        width: 56px;
        line-height: 14px;
        margin: 0 auto;
        border-bottom: 1px solid rgb(220,223,227);
        box-sizing: border-box;
        // &:last-child{
        //   border: none;
        // }
        .icon{
          display: inline-block;
          width: 12px;
          height: 12px;
          background-size:12px 12px;
          background-repeat: no-repeat;
          vertical-align: top;
        }
        .text{
          display: table-cell;
          font-size: 12px;
          font-weight:200;
          vertical-align: middle;
        }
      }
    }
    .foods-wrapper{
      flex: 1;
      .food-list{
        .list-name{
          line-height:26px;
          background:#f3f5f7;
          height: 26px;
          border-left: 3px solid #d9dde1;
        }
        h1{
          font-size: 12px;
          color: rgb(127,153,159);
          margin-left:14px;
        }
        .food{
          border-bottom: 1px solid #f3f5f7;
          padding:18px 18px 18px 18px;
          .icon{
            display: inline-block;
            vertical-align: top;
            img{
              display: block;
              height: 57px;
              width: 57px;
            }
          }
          .info{
            display: inline-block;
            margin-top: 2px;
            margin-left: 10px;
            span{
              display: block;
            }
            .title{
              font-size: 14px;
              color: rgb(7,17,27);
              line-height:14px;
            }
            .desc{
              margin-top: 8px;
              font-size: 10px;
              color:rgb(147,153,159);
              line-height:10px;
              width:130px;
              overflow:hidden;
              white-space:nowrap;
              text-overflow:ellipsis
            }
            .rating{
              margin-top: 8px;
              font-size: 10px;
              color:rgb(147,153,159);
              line-height:10px;
            }
            .price{
              font-size: 0;
              .nowP{
                font-size:14px;
                color: red;
                font-weight: 700;
                line-height: 24px;
                display: inline-block;
              }
              .oldP{
                font-size: 10px;
                color: rgb(147,153,159);
                font-weight:700;
                line-height: 24px;
                margin-left: 8px;
              }
            }
          }
        }
      }
    }
  }
</style>
